#
# Created by Administrator on 2021/7/28 AT 21:51.
#
from typing import List


class Solution:
    def smallestRangeI(self, nums: List[int], k: int) -> int:
        minVal, maxVal = min(nums), max(nums)
        return max(maxVal - minVal - 2 * k, 0)


if __name__ == '__main__':
    sol = Solution()
    print(sol.smallestRangeI(nums=[1, 3, 6], k=3))
    print(sol.smallestRangeI(nums=[1], k=0))
    print(sol.smallestRangeI(nums=[0, 10], k=2))
